<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('分配角色选择用户')" />
</head>

<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="role-form">
				    <input type="hidden" id="idUserOuter" name="idUserOuter" th:value="${user.idUserOuter}">
					<div class="select-list">
						<ul>
							<li>
								登录名称：<input type="text" name="loginName" th:value="${user.loginName}"/>
							</li>
							<li>
								用户名称：<input type="text" name="phonenumber" th:value="${user.idUserOuter}"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var dbData = [[${@baseDbService.selectAll()}]];
		$(function() {
			var options = {
				url: "/system/base/inter/notInUser?idUserOuter="+$("#idUserOuter").val(),
				modalName: "接口管理",
				columns: [{
					checkbox: true
				},
					{
						field: 'idInter',
						title: '主键',
						visible: false
					},
					{
						field: 'na',
						title: '名称'
					},
					{
						field: 'euClass',
						title: '分类'
					},
					{
						field: 'idDb',
						title: '数据源',
						formatter: function(value, item, index) {
							var name="";
							$.each(dbData,function (index,entry) {
								if(entry.idDb==parseInt(item.idDb)) {
									name = entry.na;
									return false;
								}
							});
							return name;
						}
					},
					{
						field: 'des',
						title: '备注'
					}]
			};
			$.table.init(options);
		});
		
		function queryParams(params) {
			var search = $.table.queryParams(params);
			search.roleId = $("#roleId").val();
			return search;
		}
		
		/* 添加用户-选择用户-提交 */
		function submitHandler() {
			var idInters = $.table.selectColumns('idInter');
			if(idInters.length<1) {
				$.modal.alertError("至少需要选择一条数据");
				return ;
			}
            var param=[];
			var idUserOuter = $("#idUserOuter").val();
			$.each(idInters,function (index,item) {
				param.push({"idUserOuter":idUserOuter,"idInter":item});
			});
			$.ajax({
				url: "/system/user/outer/inter/addBatch",
				type: 'POST',
				dataType: 'json',
				data: JSON.stringify(param),
				contentType: 'application/json;charset=UTF-8',
				success: function (result) {
					if(result.code=="0") {
						$.modal.close();
					}
				}
			});
		}
	</script>
</body>
</html>